home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
- #include "DeskLib:WimpSWIs.h"
-
- #include "Shell.Extra.h"
- #include "Shell.BarGraph.h"
- #include "Shell.SafeAlloc.h"
-
-
-
-
-
- typedef struct {
- int spacing;
- int barwidth;
- int *data;
- int numbars;
- int forecol, backcol;
- }
- Shell_barinfo;
-
-
- static void Shell_BarRedrawer(
- Shell_convertpoint convert,
- wimp_point rectsize,
- void *reference,
- const wimp_rect *redrawrect
- )
-
- { Shell_barinfo *barinfo = (Shell_barinfo *) reference;
- int imin, imax, i;
-
- imin = redrawrect->min.x / barinfo->spacing;
- imax = redrawrect->max.x / barinfo->spacing + 1;
-
- Shell_MakeGE( imin, 0);
- Shell_MakeLE( imax, barinfo->numbars);
-
- for ( i=imin; i<imax; i++) {
- int y = (int) barinfo->data[i];
- int x = i*barinfo->spacing;
-
- Wimp_SetColour( barinfo->forecol);
- Shell_RectangleFill2(
- x, 0,
- x + barinfo->barwidth, y,
- convert);
-
- if ( y!=rectsize.y) {
- Wimp_SetColour( barinfo->backcol);
- Shell_RectangleFill2(
- x, y,
- x + barinfo->barwidth, rectsize.y,
- convert
- );
- }
- }
-
- return;
- }
-
-
-
-
- Shell_rectblock *Shell_AddBarGraph(
- Shell_windblock *wind,
- int x, int y,
- int numbars, int spacing, int barwidth, int maxheight,
- int *data,
- int forecol, int backcol
- )
- {
- Shell_barinfo *barinfo = (Shell_barinfo *) Shell_SafeMalloc( sizeof( Shell_barinfo));
- Shell_rectblock *rect;
-
- barinfo->spacing = spacing;
- barinfo->barwidth = barwidth;
- barinfo->data = data;
- barinfo->numbars = numbars;
- barinfo->forecol = forecol;
- barinfo->backcol = backcol;
-
- rect = Shell_AddRectangle3( wind, x, y, spacing*numbars, maxheight, Shell_BarRedrawer, barinfo);
- Shell_MakeRectIcon( rect, forecol, backcol, "r2");
- return rect;
- }
-
-
-
-